#pragma once

#include "Misc/CommonMacros.h"
#include "Containers/SharedObjectPtr.h"
#include "AssetPath.h"

enum class EAssetType
{
    Undefined,
    Minimal, //minimal asset, only contains nessary data in published application
    Editable, //can be edited in editor
};

enum class EAssetSection
{
    Head =0b00001,
    MainObject =0b00010,
    EditInfoObject =0b00100,
    Thumbnail =0b01000,

    MainObjectAndEditInfoObject = MainObject|EditInfoObject,
    MainObjectAndThumbnail= MainObject|Thumbnail,
    MainObjEditObjAndThumbnail = MainObject|EditInfoObject|Thumbnail,
    AllObjects=MainObjEditObjAndThumbnail,
};

class RTexture2D;

//asset head maybe loaded many times , so it is must be small
struct SAssetHead
{
public:
    uint64_t HeadSize=0;

    EAssetType AssetType=EAssetType::Undefined;

    //create asset path of this asset
    SAssetPath CreateAssetPath(
        const CString PackageName, 
        const CString FolderPathInPackage
    ) const;

    //assets that this asset depends on
    TVector<SAssetPath> Dependencies;

    //external objects that objects in this asset depends on
    TVector<CString> ExternalObjects;

    //all object saved in this asset,
    TVector<CString> InternalObjects;

    //thumbnail of the asset.  asset maybe do not have thumbnail
    //only valid when AssetType==EAssetType::Editable
    //if have thumbnail, you can load a SAssetThumbnail from asset
    uint32_t ThumbnailSize=0;
    uint32_t GetThumbnailOffset() const
    {
        return HeadSize;
    }

    //size of the main object section
    //the head of the main object is binary data
    //and then is json data
    uint32_t MainObjectSize=0;
    //size of binary data of the main object
    //MainObjectBinarySize<=MainObjectSize
    uint32_t MainObjectBinarySize=0;
    uint32_t GetMainObjectOffset() const
    {
        return HeadSize+ThumbnailSize;
    }

    uint32_t GetMainObjectJsonOffset()
    {
        return GetMainObjectOffset()+MainObjectBinarySize;
    }

    //is asset have edit info object
    //for asset that import from raw file, this value is always false,they don't have edit info object
    //only valid when AssetType==EAssetType::Editable
    uint32_t EditInfoObjectSize=0;
    uint32_t GetEditInfoObjectOffset() const
    {
        return HeadSize+ThumbnailSize+MainObjectSize;
    }


    uint32_t GetAssetSize()
    {
        return HeadSize+ThumbnailSize+MainObjectSize+EditInfoObjectSize;
    }

    CString AssetName;

    //class name of the main object
    CClass* MainObjectClass;

};